package NovelBar.controller;

import NovelBar.dto.ChapterDto;
import NovelBar.entity.Chapter;
import NovelBar.dto.OneChapterInfo;
import NovelBar.service.ChapterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ChapterController {
    @Autowired
    private ChapterService chapterService;

    @RequestMapping("/public/loadNewChapterByBookId")
    public Chapter loadNewChapterByBookId(Integer bid) {
        return chapterService.loadNewChapterByBookId(bid);
    }

    @RequestMapping("/public/insertChapter")
    public void insertChapter(Chapter chapter) {
        chapterService.insertChapter(chapter);
    }

    @RequestMapping("/public/getChapterByBookId")
    public List<Chapter> getChapterByBookId(Integer bookId){
        return chapterService.getChapterByBookId(bookId);
    }

    @RequestMapping("/public/getOneChapterById")
    public OneChapterInfo getOneChapterById(Integer chapterBookId,Integer bookId){
        return chapterService.getOneChapterById(chapterBookId,bookId);
    }

    @RequestMapping("/public/updateVip")
    public void updateVip(ChapterDto chapterDto){
        chapterService.updateVip(chapterDto);
    }
}
